import { userProfileDisable, userProfileList, userProfileRemove, userProfileResetPassword, userProfileStatus } from "@/services/userProfile";
import { formatMessage } from 'umi-plugin-react/locale';
import { Button, Col, DatePicker, Form, Input, Layout, Modal, Radio, Row, Select, Spin, Table, message } from "antd";
import moment from "moment";
import React from "react";
import UpdateUser from "./updateUser";
import tableDataCheck from "@/utils/isBackPrevPage";
import BatchModal from "./batchModal";

import styles from "@/pages/SelfBuiltAccount/index.less"
import { AuthUserList, TreeShape } from "@/utils/CommonComponent";
import AppUsers from "./appUsers";
import BookUser from "./bookUser";
import AdminUser from "./adminUser";

const { Header, Footer, Sider, Content } = Layout;

class UserProfile extends React.Component {
  constructor(props) {
    super(props)
    this.state = {
      radioValue:1
    }
  }

  componentDidMount() {
    this.AppUsers.getTreeData('init')
  }

  changeRadio = (e) => {
    this.setState({
      radioValue:e.target.value
    },() => {
      if(e.target.value == 1){
        //应用用户
        this.AppUsers.getTreeData('init')
      }else{
        //通讯录用户
        this.AdminUser.doSearch(1,10)
      }
    })
  }

  render() {
    const { radioValue } = this.state
    const { applicationId } = this.props;
    return (
      <div style={{height:"100%"}}>
        <Radio.Group value={radioValue} onChange={this.changeRadio} style={{marginBottom:10}}>
          <Radio.Button value={1}>{formatMessage({ id: 'userProfile.appUsers' })}</Radio.Button>
          <Radio.Button value={2}>{formatMessage({ id: 'userProfile.adminUsers' })}</Radio.Button>
        </Radio.Group>

        {
          radioValue == 1 ? (
            <AppUsers onRef={ref => this.AppUsers =ref } applicationId={applicationId} />
          ) : ''
        }
        {
          radioValue == 2 ? (
            <AdminUser onRef={ref => this.AdminUser = ref} applicationId={applicationId} pageSource='application' />
          ) : ''
        }
        
      </div>

        
    )
  }
}

export default UserProfile